package no26;

class Solution {
    public int removeDuplicates(int[] nums) {
        int indexFront = 0;
        int indexBehind = 1;
        while (indexBehind <nums.length){
            if (nums[indexFront] == nums[indexBehind]){
                indexBehind++;
            }else if (nums[indexFront] != nums[indexBehind]){
                nums[indexFront+1] =nums[indexBehind];
                indexFront++;
                indexBehind++;
            }
        }

        return indexFront+1 ;
    }
}